package net.lzzy.practices.repositories;

import net.lzzy.practices.entities.Course;
import net.lzzy.practices.entities.User;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

/**
 * @author  Jaymo on 2022/5/19.
 * Description:
 */
public interface CourseRepository extends JpaRepository<Course, UUID> {
              List<Course>   findAllByOrderByUpdateTimeDesc();
              List<Course>   findCoursesByOpenEqualsOrderByUpdateTimeDesc(boolean open);
              List<Course>   findAllByOrderByUpdateTimeDesc(Pageable pageable);
              List<Course>   findCoursesByOpenEqualsOrderByUpdateTimeDesc( Pageable pageable,boolean open);
              Integer countAllBy();
              Integer countCourseByOpenEquals(boolean open);
              List<Course> findCoursesByTeacherIdEqualsOrderByCreateTimeDesc(UUID id);
              List<Course> findCoursesByStudentsContainsAndOpenOrderByUpdateTimeDesc(User student, boolean open);
}
